package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.HosptialService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/*==========================================
      时 间:   2022-03-08
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {


    @Autowired
    private HosptialService hosptialService;


    //updateStatus
    @PutMapping("/updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable String id,
                          @PathVariable Integer status){
        hosptialService.updateStatus(id,status);
        return R.ok();
    }

    @GetMapping("/{pageNum}/{pageSize}")
    public R getHospitalPage(@PathVariable Integer pageNum,
                             @PathVariable Integer pageSize,
                             HospitalQueryVo hospitalQueryVo){

      Page<Hospital> page= hosptialService.getHospitalPage(pageNum,pageSize,hospitalQueryVo);

      return R.ok().data("pages",page);
    }

    //根据医院id查询医院的详情信息
    @GetMapping("/detail/{id}")
    public R getHospitalDetailById(@PathVariable String id){
        Hospital hospital = hosptialService.getHospitalDetailById(id);
        return R.ok().data("hospital",hospital);
    }
}
